package com.ycg.blog.controller;

import com.ycg.blog.common.PageView;
import com.ycg.blog.common.R;
import com.ycg.blog.pojo.dto.ArticleDto;
import com.ycg.blog.pojo.dto.PageCondition;
import com.ycg.blog.pojo.vo.ArticleInfoVo;
import com.ycg.blog.pojo.vo.ArticleVo;
import com.ycg.blog.pojo.vo.ContentArticleVo;
import com.ycg.blog.pojo.vo.StateVo;
import com.ycg.blog.service.ArticleService;

import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;



/**
 * @author YCG
 * @date 2024-02-28 12:37
 * @description 文章增删改查
 */
@RequestMapping("/article")
@RestController
public class ArticleController {

    @Resource
    private ArticleService articleService;

    @PostMapping("/add")
    public R<String> addOrUpdateArticleInfo(@RequestBody ArticleDto articleDto) {
        return  articleService.addOrUpdateArticleInfo(articleDto);
    }

    @GetMapping("/list")
    public R<PageView<ArticleVo>> getArticleInfoList(PageCondition pageCondition) {
        return  articleService.getArticleInfoList(pageCondition);
    }

    @GetMapping("/state")
    public R<StateVo> getState() {
        return articleService.getState();
    }

    @GetMapping("/get")
    public R<ArticleInfoVo> getArticleInfo(Integer articleId) {
        return  articleService.getArticleInfo(articleId);
    }

    @GetMapping("/detail")
    public R<ArticleVo> getDetailArticle(Integer articleId) {
        return  articleService.getDetailArticle(articleId);
    }

    @GetMapping("/content")
    public R<PageView<ContentArticleVo>> getContentArticleByCategoryName(Integer current, String categoryName) {
        return  articleService.getContentArticleByCategoryName(current, categoryName);
    }

    @GetMapping("/about")
    public R<Integer> getAboutMeId() {
        return  articleService.getAboutMeId();
    }

}
